<?php require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($_SERVER['DOCUMENT_ROOT']."/Modules/MGK20XF5/moduleconf.php");
MYDCONN();
  $GetElement = $GLOBALS['MYD']->db_array("SELECT 
					a.Ref,
					a.Title,
					a.Body,
					a.Time,
					YEAR(a.Time) AS Y,
					a.Author,
					a.DocRefer,
					reportreq_Note,
					sug_Name AS Attrib,
					hcdc_types.NAME AS TYPE,
					Dcr_Note,
					TIMEREAD,
					main_offices.name AS ddocArea
				FROM doccenter_document AS a
				INNER JOIN hcdc_types ON hcdc_types.REF = a.TYPE
				INNER JOIN sys_usergroups ON sug_ID = a.Attrib
				INNER JOIN main_offices ON main_offices.ref = ddocArea
				LEFT OUTER JOIN doccenter_userreads ON DOC = a.Ref AND USER = {$_SESSION[$SESSID]}
				WHERE a.Ref = {$_GET['Iv']}"); 
		
 if(!isset($_GET['DsplMode'])) {
	mn_field('hidden','ED','DOC',$GetElement[1]['Ref'],'','','False','');
	echo '<div class="title">Propriedades do Documento | ';
			mn_field('button','ED','Check','Imprimir','','','False','" onclick="
				document.doccenter_show.action=\''.$MODURL.'lib/frm_document.php?DsplMode=Print&Iv='.$_GET['Iv'].'\';
				document.doccenter_show.target=\'_blank\';	
				submit();');
if(!isset($_GET['DsplMode'])) {
	echo ' | Confirmação de conhecimento: <div id="read_confirm">'; 
	if (isset($GetElement[1]['TIMEREAD'])) {
			echo '<div class="Confirm">'.$GetElement[1]['TIMEREAD'].' - '.$GetElement[1]['Dcr_Note'].'</div>';
	} elseif ($GetElement[1]['reportreq_Note'] == 1) {
			mn_field('button','ED','Check','Tomei Conhecimento','','','','" onclick="
		var properties = new Ext.Window({
		title:\'Notas\',
		autoLoad: \''.$GLOBALS['URL'].'Modules/MGK20XF5/req_note.php\',
		id:\'win_comconf\',
		width:400,
		height:200,
		closable:true,
		resizable:false
		});
		properties.show();');
	} else {
/*
		mn_field('button','ED','Check','Tomei Conhecimento','','','','" onclick="
		document.doccenter_show.action=\''.$MODURL.'lib/pr_confirmread.php\';
		subform(\'doccenter_show\',\'read_confirm\');');
*/
	$_POST['requestreq_Note'] = null;
	$_POST['DOC'] = $GetElement[1]['Ref'];
	include($MODPAD.'lib/pr_confirmread.php');
	}
    }	
	echo '</div>';
 } else {
 	echo '<script charset="utf-8" type="text/javascript">window.print();</script>';
 }
echo '<div style="margin:4px;padding:4px;background-color:#F2F2F2">'.strtoupper($GetElement[1]['ddocArea']).'
		<br>'.$GetElement[1]['TYPE'].': '.$GetElement[1]['DocRefer'].'/'.$GetElement[1]['Y'].'
		<br><b>'.$GetElement[1]['Title'].'</b></div>
      <div style="margin:4px;padding:4px;background-color:#DFE4D6">Anexos</br>';
	 $files = $GLOBALS['MYD']->db_array("SELECT FILE FROM doccenter_files WHERE DOC = {$GetElement[1]['Ref']}"); 
	for ($g = 1; $g<= $files[0]; $g++) { 
       echo '<div style="background-color:#DFE4D6"><a href="'.$GLOBALS['URL'].'Shared/Grx/doccenter.mex?IMG='.$files[$g]['FILE'].'">'.$files[$g]['FILE'].'</a></div>';
	}
    echo '</div>
   <div style="margin:4px;padding:4px;background-color:#F2F2F2">'.nl2br($GetElement[1]['Body']).'</div>
   <div style="margin:4px;padding:4px;background-color:#F2F2F2">Responsável: '.$GetElement[1]['Attrib'].'</div>
   <div style="margin:4px;padding:4px;background-color:#F2F2F2">Assinado. '.nl2br($GetElement[1]['Author']).'</div>';
    
			echo '</div>';